<template>
  <a-tree-select
    multiple
    :disabled="disabled"
    :value="value"
    @change="onChange"
    style="width: 100%"
    :dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
    :tree-data="treeData"
    :placeholder="placeholder"
    tree-default-expand-all
  >
  </a-tree-select>
</template>

<script>
// import { treeData } from './data.js'
import { getRiskCondition } from '@/api/project/projectypes'

export default {
  name: 'TreeSelect',
  props: {
    value: {
      type: Array
    },
    disabled: {
      type: Boolean,
      default: false
    },
    placeholder: {
      type: String,
      default: '请选择'
    }
  },
  created() {
    // 获取数据
    getRiskCondition().then(res => {
      if (res.data.success) {
        this.treeData = JSON.parse(res.data.message)
        return
      }
      this.$message.warning(res.data.message)
    })
  },
  data() {
    return {
      treeData: []
    }
  },
  methods: {
    onChange(v) {
      this.$emit('change', v)
    }
  }
}
</script>

<style lang="less">
.ant-select-tree-title {
  width: 100%;
}
</style>
